class FlexView::TemplateHandler
  def initialize(action_view)
    Logger.new(STDOUT).info 'called initialize'
    Logger.new(STDOUT).info action_view.class
    @action_view = action_view
  end
  
  def render(template, local_assigns)
    @view.instance_eval do
     # inject local assigns into reader methods
      local_assigns.each do |key, value|
        class << self; self; end.send(:define_method, key) { val }
      end
    end
    
    view = FlexView::View.new(template.filename)
    view.render local_assigns
  end
  
  def self.call(template)
    "#{name}.new(self).render(template, local_assigns)"
  end
end